from llama_index.llms.openai import OpenAI
from llama_index.core.agent.workflow import FunctionAgent

llm=OpenAI(model="gpt-4.1-nano",
                   api_key="sk-CftUbVSsA61lwwgMz9xvt6znTunQZfgBP8ZCVLbQsKfXUR6k",
                   api_base="https://www.henapi.top/v1",)


def multiply(a: float, b: float) -> float:
    """Multiply two numbers and returns the product"""
    return a * b


def add(a: float, b: float) -> float:
    """Add two numbers and returns the sum"""
    return a + b


workflow=FunctionAgent(
    tools=[multiply,add],
    llm=llm,
    system_prompt="You are an agent that can perform basic mathematical operations using tools.",
)

async def main():
    response = await workflow.run(user_msg="What is 20+(2*4)?")
    print(response)


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())